<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility"%>
<%@ include file="/public/header.jsp"%>
<%
	Map<String, Object> sessionMap = (Map<String, Object>) session.getAttribute("LOGIN_USER");
	String person_id = String.valueOf(sessionMap.get("id"));
	String person = String.valueOf(sessionMap.get("truename"));
%>
<html>
	<head>
		<title>已还欠款</title>
	<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery("#dept_id").combotree({
			url:'<%=contextPath %>/springMVC/group/listDepartment',
			method:'POST',
			animate:true,
			lines:true,
			onChange:function(){
				doSearch();
			}
		});
			
		jQuery("#user_name").keypress(function(e) { 
	    	// 回车键事件 
	     	if(e.which == 13) { 
	     		 doSearch();
	       	} 
		});
		
		jQuery("#table").datagrid({
			title:"已还欠款",
			iconCls:'icon-save',
			loadMsg:'正在加载数据，请稍后......',
			url:'<%=contextPath %>/springMVC/finance/listPageFinanceLoan?status_flag=3&has_finished=1&yet_flag=2&dev=1',
			rownumbers:true,
			fitColumns:true,
			idField:'id',
			frozenColumns:[[
			      {title:'主键',field:'id',hidden:true}
			]],
			columns:[[
				{title:'日期',field:'operation_time',width:100,align:'center'},
				{title:'申请人id',field:'user_id',width:100,align:'center',hidden:true},
				{title:'申请人',field:'user_name',width:100,align:'center'},
				{title:'金额',field:'money',width:100,align:'center'},
				{title:'所属部门',field:'dept_name',width:100,align:'center'},
				{title:'摘要',field:'summary',width:200,align:'center'},
				{title:'查看详情',field:'opMore',width:100,align:'center',formatter:function(value,rowData,rowIndex){
						var str="";
	                    	str+= "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='详情' onclick=\"javascript:viewFl('"+rowData.id+"');\"/>";
	                    return str;
				}}
				
			]],
			view: detailview,
			detailFormatter:function(index,row){
				return '<div style="padding:2px"><table class="ddv"></table></div>';
			},
			onExpandRow: function(index,row){
				var loan_id = row.id;
				var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');
				 ddv.datagrid({
					title:'还款单明细',
					url:'<%=contextPath%>/springMVC/finance/listPageFinanceLoanYet?loan_id='+loan_id,
					loadMsg:'正在加载数据，请稍后......',
					fitColumns:true,
					rownumbers:true,
					frozenColumns:[[
								      {title:'主键',field:'id',hidden:true},
								      {title:'借款单id',field:'loan_id',hidden:true}
								]],
								columns:[[
									{title:'还款日期',field:'operation_time',width:100,align:'center'},
									{title:'还款人',field:'user_name',width:100,align:'center'},
									{title:'还款金额',field:'yet_money',width:100,align:'center'},
									{title:'备注',field:'summary',width:200,align:'center'}
					]],
					pageSize:10,
					pageList : [10,50,100],  
					pagination:true,
				 	onResize:function(){
				        $('#table').datagrid('fixDetailRowHeight',index);
				    },
				 	onLoadSuccess:function(){
				       setTimeout(function(){
				         $('#table').datagrid('fixDetailRowHeight',index);
				       },0);
				   }
				 });
				 $('#table').datagrid('fixDetailRowHeight',index);
			},
			pageSize:10,
			pageList : [10,50,100],  
			pagination:true,
			onLoadSuccess:function(rtJson){
				if(rtJson.rtState== '1')
				{
					$.messager.alert('提示',rtJson.rtMsrg);
				}
			}
		});
	});
	
	function viewFl(id){
		openDialogResize("<%=contextPath %>/springViews/finance/addOrEditFinanceLoan.jsp?isShow=1&id="+id,1000, 800);
	}

	
		function doSearch() {
			var start_time=jQuery('#start_time').datebox('getValue');  
			var end_time=jQuery('#end_time').datebox('getValue'); 
			var user_name=jQuery('#user_name').val();
			var dept_id = $('#dept_id').combotree('getValue');
			jQuery('#table').datagrid('load', {
				start_time:start_time,
				end_time:end_time,
				user_name:user_name,
				dept_id:dept_id
			});
		}
	</script>
	</head>
	<body style="height:97%">
			<div id="table"  data-options="toolbar:'#tb',fit:true"></div>  
				<div id="tb" style="padding:3px;height:auto">
				<div style="float:left;">
			</div>
			<div align="right">
				所属部门：<input type="text" id="dept_id" name="dept_id"   style="width:150px">
				开始时间：<input id="start_time" name="start_time" class="easyui-datebox" style="width:100px" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" style="width:100px"/>
				申请人：<input type="text" id="user_name" name="user_name"   style="width:100px">
					<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
			</div>
		</div>
	</body>
</html>